package com.lening.organization.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lening.common.base.BaseController;
import com.lening.organization.dto.DepartmentDTO;
import com.lening.organization.po.Department;
import com.lening.organization.service.DepartmentService;
import com.lening.organization.service.impl.DepartmentServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.xml.transform.Result;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("department")
public class DepartmentController extends BaseController<Department, DepartmentDTO, DepartmentServiceImpl> {

    @Resource
    private DepartmentService departmentService;

    @GetMapping(value = "findDepartment")
    public Page<Department> findDepartment(Integer pageNum, Integer pageSize, Page<DepartmentDTO> departmentDTO) {
        Page<Department> departmentList = departmentService.findDepartment(pageNum, pageSize, departmentDTO);
        return departmentList;
    }

    @GetMapping(value = "/findByParentId/{parentId}")
    public Result findByParentId(@PathVariable Long parentId){
        List<Department> departmentList = departmentService.findByParentId(parentId);
        return (Result) departmentList;
    }

}
